package com.zhou.bjgl.bjgl.business_web.controller;


import com.zhou.bjgl.bjgl.myAnnotations.UserLoginToken;
import com.zhou.bjgl.bjgl.req.b_college.BCollegeQueryReq;
import com.zhou.bjgl.bjgl.resp.BCollegeResp;
import com.zhou.bjgl.bjgl.resp.PageResp;
import com.zhou.bjgl.bjgl.resp.common.ApiRestResponse;
import com.zhou.bjgl.bjgl.business_web.service.BCollegeSerive;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  学院管理
 * </p>
 *
 * @author jz
 * @since 2021-07-04
 */
@RestController
@RequestMapping("/bjgl/college")
@Api("学院管理")
public class BCollegeController {
    @Resource
    private BCollegeSerive bCollegeSerive;

    @ApiOperation("添加或修改学院")
    @PostMapping("/add")
    @UserLoginToken
    public ApiRestResponse add(@RequestBody BCollegeQueryReq req){
        req.setParentId(1484744242220589057L);
        bCollegeSerive.add(req);
        return ApiRestResponse.success();
    }

    @ApiOperation("删除学院方法")
    @PostMapping("/delete")
    @UserLoginToken
    public ApiRestResponse delete(@RequestBody BCollegeQueryReq req) {
        bCollegeSerive.delete(req);
        return ApiRestResponse.success();
    }

    @ApiOperation("获取学院列表")
    @GetMapping("/list")
    @UserLoginToken
    public ApiRestResponse list(BCollegeQueryReq req) {
        PageResp<BCollegeResp> collegeList = bCollegeSerive.listCollege(req);
        return ApiRestResponse.success(collegeList);
    }
}

